<?php

namespace app\api\exception;

use Exception;

/**
 * API业务异常类
 */
class ApiException extends Exception
{
    protected $errorCode;
    protected $httpCode;
    protected $errorData;

    public function __construct(
        string $message = '',
        int $errorCode = 0,
        int $httpCode = 400,
        array $errorData = [],
        Exception $previous = null
    ) {
        parent::__construct($message, $errorCode, $previous);
        $this->errorCode = $errorCode;
        $this->httpCode = $httpCode;
        $this->errorData = $errorData;
    }

    public function getErrorCode(): int
    {
        return $this->errorCode;
    }

    public function getHttpCode(): int
    {
        return $this->httpCode;
    }

    public function getErrorData(): array
    {
        return $this->errorData;
    }
}
